package org.bim.view.drag.design.config;
import lombok.AllArgsConstructor;
import org.bim.view.drag.design.interceptor.AuthInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.handler.MappedInterceptor;

/**
 * @author huangr
 * @date 2021/12/17 2:53 下午
 */
@Configuration
@AllArgsConstructor
public class WebConfiguration implements WebMvcConfigurer {
    private final AuthInterceptor authInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] includes = new String[]{
                "/**"
        };
        String[] exclude = new String[]{
                "/login",
                "/register",
                "/sso/login",
                "/check-token",
                "/*.js",
                "/*.html",
                "/*.css",
                "/doc.html",
                "/swagger-ui.html",
                "/swagger**",
                "/v2/**",
                "/webjars/**",
                "/visual/detail",  //获取配置详情接口 放开，才能预览
                "/map/list",    //获取地图列表，获取地图详情接口放开
                "/map/detail",
                "/map/data",
                "/map/data**",
                "/data/proxy",  // 后端数据代理
                "/db/dynamic-query", //数据库查询接口
        };
        MappedInterceptor mappedInterceptor = new MappedInterceptor(includes, exclude, authInterceptor);
        registry.addInterceptor(mappedInterceptor);
    }

}
